<template>
  <div class="app-container">
    <el-form label-width="120px">

      <el-form-item label="用户名">
        <el-input v-model="info.username" placeholder="请输入"/>
      </el-form-item>

      <el-form-item label="电话">
        <el-input v-model="info.tel" placeholder="请输入"/>
      </el-form-item>

      <el-form-item label="邮箱">
        <el-input v-model="info.email" placeholder="请输入"/>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="store_userinfo">修改</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import user from '@/api/hr/user'
export default {
  data() {
    return {
      info: {}
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      this.get_userinfo()
    },
    get_userinfo() {
      user.getOne()
        .then(response => {
          if (response.data.user !== null) {
            this.info = response.data.user
            console.log(this.info.username)
          } else {
            this.info = {}
          }
        })
    },
    store_userinfo() {
      user.updateUser(this.info)
        .then(response => {
          this.$message({
            type: 'success',
            message: '存储成功!'
          })
          this.$router.push({ path: '/user/user-info' })
        })
    }
  }
}
</script>

<style scoped>

</style>
